<template>
	<view>
		<u-navbar title="个性签名">
			<view slot="right" class="u-p-x-16 u-p-y-4 u-m-r-30 radius bg-blue" @tap="save" :class="{'bg-grey':!motto,'bg-blue':motto}">
				<text class="u-font-28">保存</text>
			</view>
		</u-navbar>
		<view class="u-m-t-20 bg-white u-p-30">
			<textarea class="u-font-28" style="width: 100%;height: 200rpx;" maxlength="50" v-model="motto" placeholder="请输入个性签名"/>
			<view class="text-gray u-text-right u-m-t-20">
				<text>{{motto.length}}/50</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {goback} from '@/utils/util.js'
	import {modifyUser} from "@/api/user.js"
	import {mapGetters,mapMutations} from "vuex"
	export default {
		data() {
			return {
				motto:''
			};
		},
		computed:{
			...mapGetters('user',['userInfo'])
		},
		onLoad() {
			this.motto = this.userInfo.profiles
		},
		methods:{
			...mapMutations('user',['mixUserInfo']),
			async save(){
				if(this.save.lock||!this.motto){
					return
				}
				try{
					this.save.lock=true
					await modifyUser({profiles:this.motto})
					
					this.mixUserInfo({profiles:this.motto})
					goback()
				}finally{
					this.save.lock=false
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
